<?php
/**
 * 
 * @author top
 *
 */
class TagController extends Controller {
	
	public $defaultAction = 'tag';
	
	/**
	 *
	 * @param $t string       	
	 */
	public function actionTag() {
		$criteria = new CDbCriteria ();
		$criteria->order = "odr asc";
		
		$tags = Tags::model ()->findAll ( $criteria );
		
		$sub_tags = array ();
		
		$educators = Educators::model ();
		
		$dataProvider = $educators->search ();
		
		$this->render ( 'tag', array ('dataProvider' => $dataProvider, 'sub_tags' => $sub_tags, 'tags' => $tags ) );
	}
	
	/**
	 *
	 * @param $t string       	
	 */
	public function actionList($tag = false, $sub_tag = false) {
		$criteria = new CDbCriteria ();
		$criteria->order = "odr asc";
		
		$tags = Tags::model ()->findAll ( $criteria );
		
		$sub_tags = array ();
		
		$educators = Educators::model ();
		
		if ($tag) {
			
			$educators->eduer_tags = $tag;
			$tag_model = Tags::model ()->findByAttributes ( array ('name' => $tag ) );
			$sub_id = $tag_model->id;
			$sub_tags = SubTags::model ()->findAllByAttributes ( array ('sub_id' => $sub_id ) );
		
		}
		
		$dataProvider = $educators->search ();
		
		$this->render ( 'tag', array ('dataProvider' => $dataProvider, 'sub_tags' => $sub_tags, 'tags' => $tags ) );
	}

}